/*  header-comment
/*  file   : /Users/arida/react-hrm-h5/src/actions/steps/getFiles
/*  author : arida
/*  date   : 2017-6-4 18:27:47
/*  last   : 2017-8-4 17:38:10
*/
import { createAction } from "redux-actions";

import fetch from "../../utils/fetch.js";
import { get } from "../../utils/db";

export const getUploadedFiles = createAction("STEP_ONE_GET_FILES");
export const getUser = createAction("STEP_ONE_GET_USER");

export const fetchUploadedFiles = () => dispatch =>
  fetch(`${get("baseUrl")}getUploadedMaterialV2`, {
    meta: {
      dipId: 65280
    }
  }).then(res => {
    if (res.success) {
      dispatch(getUploadedFiles(res.result));
    }
    return res;
  });

export const saveUploadedFiles = formData => () =>
  fetch(`${get("baseUrl")}uploadMaterial`, {
    body: formData,
    meta: {
      dipId: 63662
    }
  });

export const getFileKey = file => () =>
  fetch(`${get("baseUrl")}uploadImage`, {
    body: file,
    meta: {
      dipId: 63659
    }
  });
export const getSchoolData = schoolName => () =>
  fetch("/hrmregister/mobile/common/school/query", {
    body: {
      schoolName
    },
    meta: {
      dipId: 65584,
      silence: true
    }
  });
export const getSchoolInitData = (schoolName, params = {}) => () =>
  fetch("/hrmregister/mobile/common/school/queryByFullName", {
    body: {
      schoolName
    },
    meta: {
      dipId: 65831,
      silence: true,
      showLoading: params.showLoading
    }
  });
